# -*- coding: utf-8 -*-
'''
author:Cooper
date:2012.5.3
关联推荐API
taobao.categoryrecommend.items.get	根据类目信息推荐相关联的宝贝集
taobao.itemrecommend.items.get	根据推荐类型获取推荐的关联关系商品
taobao.shoprecommend.items.get	根据店铺信息推荐相关联的宝贝集
taobao.shoprecommend.shops.get	根据店铺信息推荐相关联的店铺集
'''

from TopAPI.lib import *
import json

class catagory_recommend_items():
	api='taobao.categoryrecommend.items.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,format='json',
		catagory_id='',
		recommend_type='1',
		count='20',
		ext=None):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseItem(self):
		r=self.getRes()
		j=json.loads(r.content,r.encoding)
		return parseJsonField(j,'favorite_items')
	pass

class item_recommend_items():
	api='taobao.itemrecommend.items.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,format='json',
		item_id='',
		recommend_type='1',
		count='20',ext=None):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseItem(self):
		r=self.getRes()
		j=json.loads(r.content,r.encoding)
		return parseJsonField(j,'values')
	pass

class shop_recomment_items():
	api='taobao.shoprecommend.items.get'
	def __init__(self):
		self.method=self.api
	def setParams(self,format='json',
		seller_id='',
		recommend_type='1',
		count='20',ext=None):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseItem(self):
		def parseItem(self):
		r=self.getRes()
		j=json.loads(r.content,r.encoding)
		return parseJsonField(j,'favorite_items')
	pass
class shop_recomment_shops():
	api='taobao.shoprecommend.shops.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,format='json',
		seller_id='',
		recommend_type='1',
		count='20',ext=None):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseItem(self):
		def parseItem(self):
		r=self.getRes()
		j=json.loads(r.content,r.encoding)
		return parseJsonField(j,'favorite_shops')
	pass

def main():
	pass

if __name__=='__main__':
	main()
	pass
